package com.cell.api.web;

import com.cell.api.application.netty.server.NettyServer;
import com.cell.api.web.configure.EnableApiWebControllerStartup;
import com.cell.api.web.configure.EnableApiWebStartup;
import com.cell.util.json.JsonUtils;
import com.cell.web.AbstractCellApplication;
import org.springframework.boot.SpringApplication;
import org.springframework.context.ConfigurableApplicationContext;

import java.util.Locale;

/**
 * @author zdy
 */
@EnableApiWebStartup
@EnableApiWebControllerStartup
public class CellApiWebApplication extends AbstractCellApplication {
    static {
        //解决 es 与 Redis 冲突问题
        System.setProperty("es.set.netty.runtime.available.processors", "false");
        Locale.setDefault(Locale.CHINA);
    }

    /**
     *
     */
    public CellApiWebApplication() {
        //日期格输出自动格式化
        JsonUtils.registerDataDefaultSerialize();
    }

    public static void main(String[] args) {
        ConfigurableApplicationContext ctx = SpringApplication.run(CellApiWebApplication.class, args);
        //启动服务端
        NettyServer nettyServer = ctx.getBean(NettyServer.class);
        nettyServer.open(8090);
    }


    @Override
    protected boolean isJsonCastLongToString() {
        return true;
    }
}
